package com.service.bank.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.client.model.pojo.bank.Record;
import com.client.model.vo.common.Result;
import com.client.model.vo.common.ResultCodeEnum;
import com.client.model.vo.deposit.RecordVo;
import com.service.bank.service.RecordService;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

/**
 * @author 周佳辉
 * @date 2024/4/11
 */
@RestController
@RequestMapping("/airui/api/orders")
public class OrdersController {

    @Autowired
    private RecordService recordService;

    @GetMapping("/lists")
    @Operation(summary = "转账发起人")
    public Result<Page<Record>> lists(@RequestHeader String token,
                                     @RequestParam(value = "offset",defaultValue = "5")Integer offset,
                                     @RequestParam(value = "pagesize",defaultValue = "10")Integer pagesize){
        Page<Record>  records = this.recordService.lists(token,offset,pagesize);
        return Result.build(records, ResultCodeEnum.SUCCESS);
    }

    @GetMapping("/listorders")
    @Operation(summary = "转账接收人")
    public Result<Page<Record>> listorders(@RequestHeader String token,
                                     @RequestParam(value = "offset",defaultValue = "5")Integer offset,
                                     @RequestParam(value = "pagesize",defaultValue = "10")Integer pagesize){
        Page<Record>  records = this.recordService.listorders(token,offset,pagesize);
        return Result.build(records,ResultCodeEnum.SUCCESS);
    }

    @GetMapping("/chongorder")
    @Operation(summary = "充值交易")
    public Result<Page<Record>>  chongorder(@RequestHeader String token,
                                      @RequestParam(value = "offset",defaultValue = "5")Integer offset,
                                      @RequestParam(value = "pagesize",defaultValue = "10")Integer pagesize){
        Page<Record> records = this.recordService.chongorder(token,offset,pagesize);
        return Result.build(records,ResultCodeEnum.SUCCESS);
    }

    @GetMapping("/tixianorder")
    @Operation(summary = "提现交易")
    public Result<Page<Record>>  tixianorder(@RequestHeader String token,
                                             @RequestParam(value = "offset",defaultValue = "5")Integer offset,
                                             @RequestParam(value = "pagesize",defaultValue = "10")Integer pagesize){
        Page<Record> records = this.recordService.tixianorder(token,offset,pagesize);
        return Result.build(records,ResultCodeEnum.SUCCESS);
    }

    @DeleteMapping("/deletes")
    @Operation(summary = "删除记录")
    public Result deletes(@RequestParam(value = "rid") Long rid){
        System.out.println("rid"+rid);
        this.recordService.removeById(rid);
        return Result.build(null,ResultCodeEnum.SUCCESS);
    }
}
